package org.gitman.agentplatform.ui.summary;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.util.HashMap;
import java.util.Map;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import org.gitman.agentplatform.ui.MainFrame;
import org.gitman.agentplatform.ui.actions.ActionsManager;

public class SummaryPanel extends JPanel {
	public static String STATE = "Simulation result:";
	public static String RATING = "Simulation rating:";
	public static String ITERATIONS = "Nr of iterations:";
	public static String MIN_ITERATIONS = "Min nr of iterations:";
	public static String AGENTS = "Nr of agents:";	
	public static String VERTICES = "Nr of vertices:";
	public static String EDGES = "Nr of edges:";
	public static String TIME = "Total agents time:";
	public static String OBSERV = "Common observability:";
	public static String PREDICT = "Common predictablity:";
	public static String RELIE = "Common relieability:";
	
	private Map<String, JLabel> name2label;
	
	public SummaryPanel(MainFrame mainFrame) {
		ActionsManager actionsManager = mainFrame.getActionsManager();
		name2label = new HashMap<String, JLabel>();
		
		setLayout(new BorderLayout());
				
		JPanel buttonPanel = new JPanel(new GridLayout(1, 2));
		buttonPanel.add(new JButton(actionsManager.export2csvAction));
		buttonPanel.add(new JButton(actionsManager.showAgentsDetailsAction));
		add(buttonPanel, BorderLayout.NORTH);
		
		JPanel cenerPanel = new JPanel(new BorderLayout());
		add(cenerPanel, BorderLayout.CENTER);
		String [] params = {STATE, RATING, ITERATIONS, MIN_ITERATIONS, AGENTS, VERTICES, EDGES, TIME, OBSERV, PREDICT, RELIE};
		JPanel overAllPanel = new JPanel(new GridLayout(params.length,2));
		overAllPanel.setBorder(BorderFactory.createTitledBorder("General statistics"));
		cenerPanel.add(overAllPanel, BorderLayout.NORTH);
		
		for(String param : params){
			overAllPanel.add(new JLabel(param));
			JLabel label = new JLabel("-");
			overAllPanel.add(label);
			name2label.put(param, label);
		}		
		
	}
	public void setParam(String key, String val){
		name2label.get(key).setText(val);
	}	
}
